package com.ruoyi.crm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.crm.domain.CrmOrderPayDetails;
import com.ruoyi.crm.service.ICrmOrderPayDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 付款计划详情Controller
 *
 * @author ruoyi
 * @date 2024-11-27
 */
@RestController
@RequestMapping("/crm/payDetails")
public class CrmOrderPayDetailsController extends BaseController
{
    @Autowired
    private ICrmOrderPayDetailsService crmOrderPayDetailsService;

    /**
     * 查询付款计划详情列表
     */
    // @PreAuthorize("@ss.hasPermi('crm:payDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(CrmOrderPayDetails crmOrderPayDetails)
    {
        startPage();
        List<CrmOrderPayDetails> list = crmOrderPayDetailsService.selectCrmOrderPayDetailsList(crmOrderPayDetails);
        return getDataTable(list);
    }

    /**
     * 导出付款计划详情列表
     */
    // @PreAuthorize("@ss.hasPermi('crm:payDetails:export')")
    @Log(title = "付款计划详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CrmOrderPayDetails crmOrderPayDetails)
    {
        List<CrmOrderPayDetails> list = crmOrderPayDetailsService.selectCrmOrderPayDetailsList(crmOrderPayDetails);
        ExcelUtil<CrmOrderPayDetails> util = new ExcelUtil<CrmOrderPayDetails>(CrmOrderPayDetails.class);
        util.exportExcel(response, list, "付款计划详情数据");
    }

    /**
     * 获取付款计划详情详细信息
     */
    // @PreAuthorize("@ss.hasPermi('crm:payDetails:query')")
    @GetMapping(value = "/{payDetailsId}")
    public AjaxResult getInfo(@PathVariable("payDetailsId") String payDetailsId)
    {
        return success(crmOrderPayDetailsService.selectCrmOrderPayDetailsByPayDetailsId(payDetailsId));
    }

    /**
     * 新增付款计划详情
     */
    // @PreAuthorize("@ss.hasPermi('crm:payDetails:add')")
    @Log(title = "付款计划详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CrmOrderPayDetails crmOrderPayDetails)
    {
        return toAjax(crmOrderPayDetailsService.insertCrmOrderPayDetails(crmOrderPayDetails));
    }

    /**
     * 修改付款计划详情
     */
    // @PreAuthorize("@ss.hasPermi('crm:payDetails:edit')")
    @Log(title = "付款计划详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CrmOrderPayDetails crmOrderPayDetails)
    {
        return toAjax(crmOrderPayDetailsService.updateCrmOrderPayDetails(crmOrderPayDetails));
    }

    /**
     * 删除付款计划详情
     */
    // @PreAuthorize("@ss.hasPermi('crm:payDetails:remove')")
    @Log(title = "付款计划详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{payDetailsIds}")
    public AjaxResult remove(@PathVariable String[] payDetailsIds)
    {
        return toAjax(crmOrderPayDetailsService.deleteCrmOrderPayDetailsByPayDetailsIds(payDetailsIds));
    }
}
